Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: add driver for ST VL6180X ranging and ambient light sensor #10462

Merged
merged 5 commits into from
Feb 2, 2023

Conversation

gschorcht
Copy link
Contributor

Contribution description

This PR adds a driver for the ST VL6180X ranging and ambient light sensor. The driver can be used in two variants which differ in functionality and size:

Module Name Driver
vl6180x Driver with standard functionality and larger size
vl6180x_basic Driver with only basic functionality and smaller size

Both driver variants provide

  • continuous ranging and ambient light sensing,
  • polling for new measurement results, and
  • SAUL capabilies.

In addition to these basic functionalities, the standard driver vl6180x
provides interrupt handling, single shot measurements, a number of
configuration functions and power down / power up functionality.
Features of the driver variants are summarized in the following comparison
sheet.

Feature vl6180x_basic vl6180x
Range measurements [mm] X X
Ambient light measurements [Lux, raw] X X
SAUL capability X X
Continuous measurements X X
Single shot measurements X
Start and stop measurements X
Polling for new measurement results X X
Data-ready interrupts X
Threshold interrupts X
Measurement error status X
Configuration during run-time X
Power down and power up X
Size on reference platform 1.7 kByte 3.0 kByte

Testing procedure

Using the make command

make flash -C tests/driver_vl6180x BOARD=...

the standard driver variant vl6180x is used with the following default
configuration parameters:

  • periodic check of the availability of new data every 100 ms
  • a ranging inter-measurement period of 100 ms
  • a ranging maximum convergence time of 50 ms
  • an ambient light sensing (ALS) inter-measurement period of 500 ms
  • an ambient light sensing (ALS) integration time of 100 ms
  • an ambient light sensing (ALS) analogue light channel gain of 1.0
  • an ambient light sensing period of 500 ms
  • a ranging period of 100 ms.

To use the basic driver variant, the vl6180x_basic module has
to be specified at make command line

USEMODULE=vl6180x_basic make flash -C tests/driver_vl6180x BOARD=...

The default configuration parameters used for the test application with the
basic driver variant are the same as for the standard driver variant.

To use interrupts to fetch new data instead of polling for new data
periodically, the standard driver variant vl6180x has to be used and the
pin connected with the interrupt signal GPIO1 of the sensor has to be
defined by configuration paramater VL6180X_PARAM_PIN_INT, e.g.,

CFLAGS="-DVL6180X_PARAM_PIN_INT=\(GPIO_PIN\(0,1\)\)" make flash -C tests/driver_vl6180x BOARD=...

To test the power down and power up functionality, the pin connected with
the signal GPIO0/CE of the sensor has to be defined by configuration
paramater VL6180X_PARAM_PIN_SHUTDOWN , e.g.,

CFLAGS="-DVL6180X_PARAM_PIN_SHUTDOWN=\(GPIO_PIN\(0,2\)\)" make flash -C tests/driver_vl6180x BOARD=...

@gschorcht gschorcht added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Area: tests Area: tests and testing framework Area: drivers Area: Device drivers Area: SAUL Area: Sensor/Actuator Uber Layer labels Nov 24, 2018
@aabadie aabadie added this to the Release 2019.01 milestone Dec 3, 2018
@gschorcht gschorcht added Type: new feature The issue requests / The PR implemements a new feature for RIOT and removed Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation labels Dec 6, 2018
@aabadie
Copy link
Contributor

aabadie commented Dec 10, 2018

I have the hardware for testing this PR, I'll do a code review this week.

@gschorcht
Copy link
Contributor Author

@aabadie Thanks 😄

} vl6180x_error_t;

/**
* @brief Aanalogue gain of ALS measurements
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: Analogue

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

*/
typedef enum {
VL6180X_ALS_GAIN_20 = 0, /**< 20 x gain */
VL6180X_ALS_GAIN_100, /**< 10 x gain */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be 10 not 100 then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, of course 🕶️

uint16_t als;
uint16_t lux;

#if MODULE_VL6180X_BASIC
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be #ifdef?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why, the semantic is the same? By definition, an undefined macro can be tested for a zero. That is #if ! is exactly the same as #ifndef and #if !defined().

return (status & VL6180X_RNG_ERR_CODE) ? VL6180X_ERROR_RNG : VL6180X_OK;
}

#if !MODULE_VL6180X_BASIC
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be #ifndef

@dylad
Copy link
Member

dylad commented Aug 12, 2020

@gschorcht Could you please rebase this PR ?
I just received the hardware to test it so I can give it a try.

@dylad dylad self-assigned this Aug 12, 2020
@gschorcht
Copy link
Contributor Author

@gschorcht Could you please rebase this PR ?
I just received the hardware to test it so I can give it a try.

I'm on vacation until August 27th. Is it ok to rebase it afterwards?

@dylad
Copy link
Member

dylad commented Aug 15, 2020

No problem ! Enjoy your vacations !

@bors
Copy link
Contributor

bors bot commented Jan 24, 2023

🕐 Waiting for PR status (GitHub check) to be set, probably by CI. Bors will automatically try to run when all required PR statuses are set.

@bors
Copy link
Contributor

bors bot commented Jan 24, 2023

GitHub status checks took too long to complete, so bors is giving up. You can adjust bors configuration to have it wait longer if you like.

@maribu
Copy link
Member

maribu commented Jan 24, 2023

bors retry

@bors
Copy link
Contributor

bors bot commented Jan 24, 2023

🕐 Waiting for PR status (GitHub check) to be set, probably by CI. Bors will automatically try to run when all required PR statuses are set.

@maribu
Copy link
Member

maribu commented Jan 24, 2023

bors retry

@bors
Copy link
Contributor

bors bot commented Jan 24, 2023

🕐 Waiting for PR status (GitHub check) to be set, probably by CI. Bors will automatically try to run when all required PR statuses are set.

@maribu
Copy link
Member

maribu commented Jan 24, 2023

bors cancel
bors retry

@bors
Copy link
Contributor

bors bot commented Jan 24, 2023

🕐 Waiting for PR status (GitHub check) to be set, probably by CI. Bors will automatically try to run when all required PR statuses are set.

@maribu
Copy link
Member

maribu commented Jan 24, 2023

@gschorcht Maybe a rebase can convince bors to pick this up?

@benpicco
Copy link
Contributor

benpicco commented Feb 2, 2023

bors merge

@bors
Copy link
Contributor

bors bot commented Feb 2, 2023

🕐 Waiting for PR status (GitHub check) to be set, probably by CI. Bors will automatically try to run when all required PR statuses are set.

@benpicco benpicco added Area: SAUL Area: Sensor/Actuator Uber Layer and removed Area: SAUL Area: Sensor/Actuator Uber Layer labels Feb 2, 2023
@benpicco
Copy link
Contributor

benpicco commented Feb 2, 2023

bors merge

@bors
Copy link
Contributor

bors bot commented Feb 2, 2023

🕐 Waiting for PR status (GitHub check) to be set, probably by CI. Bors will automatically try to run when all required PR statuses are set.

@benpicco
Copy link
Contributor

benpicco commented Feb 2, 2023

This needs a rebase for bors to accept it.

@benpicco
Copy link
Contributor

benpicco commented Feb 2, 2023

bors merge

@bors
Copy link
Contributor

bors bot commented Feb 2, 2023

Build succeeded:

@bors bors bot merged commit b0fc3e5 into RIOT-OS:master Feb 2, 2023
@gschorcht
Copy link
Contributor Author

Thanks 😄

@gschorcht gschorcht deleted the drivers_vl6180x branch February 4, 2023 12:13
@MrKevinWeiss MrKevinWeiss added this to the Release 2023.04 milestone Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: doc Area: Documentation Area: drivers Area: Device drivers Area: Kconfig Area: Kconfig integration Area: SAUL Area: Sensor/Actuator Uber Layer Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.